<?php

declare(strict_types=1);

namespace app\admin\validate;

use think\Validate;

class Resource extends Validate
{
    /**
     * 定义验证规则
     * 格式：'字段名' =>  ['规则1','规则2'...].
     *
     * @var array
     */
    protected $rule = [
        'resource_id' => 'require|number|gt:0',
        'group_id' => 'require|number|gt:0',
        'resource_type' => 'require|number|in:1,2',
        'code' => 'require',
        'target' => 'require',
        'original_url' => 'require',
        'thumbnail_url' => 'require',
        'sort' => 'require|number|gt:0',
        'page' => 'require|number|gt:0',
        'limit' => 'require|number|gt:5',
        'img_file' => 'file|image',
        'status' => 'require|number|in:0,1',
        'file' => 'file',
    ];
    protected $scene = [
        'getResourceListPage' => ['page', 'limit'],
        'saveResourceAdd' => ['group_id', 'resource_type', 'code', 'original_url', 'thumbnail_url'],
        'getResourceRow' => ['resource_id'],
        'saveResourceEdit' => ['resource_id'],
        'saveResourceDel' => ['resource_id'],
        'setResourceStatus' => ['target','status'],
        'uploadImg' => ['img_file'],
        'uploadFile' => ['file'],
        'getImgPath' => ['target'],
        'cleanUpExpiredFiles'=>['file'],
    ];
}
